<template>
  <Head/>
  <Menu/>
  <el-container style="height: 100vh;">
    <el-header>
      <h1>上海理工大学食堂满意度调查</h1>
    </el-header>
    <el-main>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="角色">
          <el-select v-model="form.position" class="m-2" placeholder="Select" size="large">
            <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="部门">
          <el-select v-model="form.department" placeholder="请选择部门">
            <el-option label="一食堂" value="one"></el-option>
            <el-option label="五食堂" value="five"></el-option>
            <el-option label="阅餐厅" value="read"></el-option>
            <el-option label="思餐厅" value="think"></el-option>
            <el-option label="咪呢餐厅2" value="mice"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="满意度">
          <el-radio-group v-model="form.satisfaction">
            <el-radio label="非常满意">非常满意</el-radio>
            <el-radio label="满意">满意</el-radio>
            <el-radio label="一般">一般</el-radio>
            <el-radio label="不满意">不满意</el-radio>
            <el-radio label="非常不满意">非常不满意</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="对食堂与学校的建议">
          <el-input v-model="form.suggestion" type="textarea" placeholder="请输入建议"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
          <el-button type="primary" @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </el-main>

  <el-footer style="margin-top: 20px">
<!--  <Footer/>-->
  </el-footer >
  </el-container>
</template>

<script >
import { ref } from 'vue';
import { ElForm, ElInput, ElRadioGroup, ElSelect, ElOption } from 'element-plus';
import Head from "@/components/Head.vue";
import Menu from "@/components/Menu.vue";
import Footer from "@/components/Footer.vue";
import '@/element-plus/package.json/index.css'; // 引入Element Plus样式文件

export default {
  components: {Footer, Menu, Head, ElForm, ElInput, ElRadioGroup, ElSelect, ElOption},
  setup() {
    form.value = {};
    const form = ref({
      name: '',
      position: '',
      department: '',
      satisfaction: '',
      suggestion: ''
    });
console.log(form.value)
    const options = [
      {
        value: 'student',
        label: '学生',
      },
      {
        value: 'teacher',
        label: '教师',
      },
      {
        value: 'staff',
        label: '工作人员',
      }]
    const submitForm = () => {
      // 在这里处理表单提交逻辑，例如发送到后端服务器等。
      console.log(form.value);
    };
    const resetForm=()=>{
      form.value = {}; // 重置表单字段
    }
    return { form, submitForm ,options,resetForm};
  }
};
</script>